function error_handler(options) {
    return async (ctx, next) => {
        try{
            await next();
        }catch(err){
            console.error(err);
            ctx.response.status = err.statusCode || err.status || 500;
            ctx.response.body = {
                error: 500,
                message: err.message
            }
        }
    }
}

module.exports = error_handler;